package vn.edu.hcmut.cse.ai.infrastructure;

import java.util.LinkedList;
import java.util.List;

public class Solution {
    private final List<Action> actionList;
    
    public Solution(Node node) {
        // Get the search path of the Node and return action list
        actionList = new LinkedList<>();
        
        if (node.getParent() == null) {
            // The initial state is also the goal state
            actionList.add(new NoOpAction());
        }
        
        while (node.getParent() != null) {
            actionList.add(0, node.getAction());
            node = node.getParent();
        }
    }
 
    public List<Action> getActionList() {
        return actionList;
    }
}
